mdbt42q 2.2.0
Loading...
Searching...
No Matches
mdbt42q


MDBT42Q Click

MDBT42Q Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : May 2025.
  • Type : UART type

Software Support

Example Description

This example demonstrates the use of MDBT42Q Click board by processing data from a connected BT device.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.MDBT42Q

Example Key Functions

  • mdbt42q_cfg_setup This function initializes Click configuration structure to initial values.
    void mdbt42q_cfg_setup(mdbt42q_cfg_t *cfg)
    MDBT42Q configuration object setup function.
    MDBT42Q Click configuration object.
    Definition mdbt42q.h:226
  • mdbt42q_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t mdbt42q_init ( mdbt42q_t *ctx, mdbt42q_cfg_t *cfg );
    err_t mdbt42q_init(mdbt42q_t *ctx, mdbt42q_cfg_t *cfg)
    MDBT42Q initialization function.
    MDBT42Q Click context object.
    Definition mdbt42q.h:201
  • mdbt42q_get_ind_pin This function returns the BT connection active indicator (IND) pin logic state.
    uint8_t mdbt42q_get_ind_pin ( mdbt42q_t *ctx );
    uint8_t mdbt42q_get_ind_pin(mdbt42q_t *ctx)
    MDBT42Q get IND pin function.
  • mdbt42q_reset_device This function resets the device by toggling the reset pin logic state.
    void mdbt42q_reset_device(mdbt42q_t *ctx)
    MDBT42Q reset device function.
  • mdbt42q_cmd_run This function sends a specified command to the Click module.
    void mdbt42q_cmd_run ( mdbt42q_t *ctx, uint8_t *cmd );
    void mdbt42q_cmd_run(mdbt42q_t *ctx, uint8_t *cmd)
    MDBT42Q cmd run function.
  • mdbt42q_cmd_set This function sets a value to a specified command of the Click module.
    void mdbt42q_cmd_set ( mdbt42q_t *ctx, uint8_t *cmd, uint8_t *value );
    void mdbt42q_cmd_set(mdbt42q_t *ctx, uint8_t *cmd, uint8_t *value)
    MDBT42Q cmd set function.

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
mdbt42q_cfg_t mdbt42q_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
mdbt42q_cfg_setup( &mdbt42q_cfg );
MDBT42Q_MAP_MIKROBUS( mdbt42q_cfg, MIKROBUS_1 );
if ( MDBT42Q_OK != mdbt42q_init( &mdbt42q, &mdbt42q_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = MDBT42Q_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
#define MDBT42Q_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition mdbt42q.h:184
void application_init(void)
Definition main.c:149
@ MDBT42Q_POWER_UP
Definition main.c:66
@ MDBT42Q_OK
Definition mdbt42q.h:253

Application Task

Application task is split in few stages:

  • MDBT42Q_POWER_UP:

    Powers up the device, performs a factory reset and reads system information.

  • MDBT42Q_CONFIG_EXAMPLE:

    Sets the BT device name.

  • MDBT42Q_EXAMPLE:

    Performs a BT terminal example by processing all data from a connected BT device and sending back an adequate response messages.

void application_task ( void )
{
switch ( app_state )
{
{
if ( MDBT42Q_OK == mdbt42q_power_up( &mdbt42q ) )
{
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
{
if ( MDBT42Q_OK == mdbt42q_config_example( &mdbt42q ) )
{
app_state = MDBT42Q_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
{
mdbt42q_example( &mdbt42q );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
@ MDBT42Q_CONFIG_EXAMPLE
Definition main.c:67
@ MDBT42Q_EXAMPLE
Definition main.c:68
void application_task(void)
Definition main.c:182

Note

We have used the Serial Bluetooth Terminal smartphone application for the test.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.